package tech.realcpf.duckengine1.duckdb;

import tech.realcpf.duckengine1.biz.BizCatalog;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;

public class CatalogProcessor implements ResultProcessor{
    @Override
    public Object process(ResultSet rs, boolean close) throws SQLException {
        List<BizCatalog> bizCatalogs = new LinkedList<>();
        while (rs.next()) {
            BizCatalog bizCatalog = new BizCatalog();
            bizCatalog.setId(rs.getString("id"));
            bizCatalog.setName(rs.getString("name"));
            bizCatalog.setType(rs.getString("type"));
            bizCatalog.setTs(rs.getTimestamp("ts").toLocalDateTime());
            bizCatalog.setDdVersion(rs.getInt("dd_version"));
            bizCatalog.setFileExt(rs.getString("file_ext"));
            bizCatalogs.add(bizCatalog);
        }
        return bizCatalogs;
    }
}
